package cn.eeepay.boss.system;

import cn.eeepay.framework.util.Constants;
import cn.eeepay.framework.util.StringUtil;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        String typeKey = DynamicDataSourceHolder.getDataSource();
        if(StringUtil.isBlank(typeKey)) {
            return Constants.DATA_SOURCE_MASTER;
        }
        return typeKey;
    }
}
